/*!
 * Simplex Admin Template - Version 1.0
 *
 * Copyright 2011, Prosoftware.pl Dominik Cwiklik
 * @see http://www.prosoftware.pl/simplex-admin-template/
 * @license MIT http://www.opensource.org/licenses/mit-license.php
 *
 * Includes jQuery | http://jquery.com/ | Copyright 2011, John Resig | Dual licensed under the MIT or GPL Version 2 licenses.
 * Includes Uni-form | http://sprawsm.com/uni-form/ | Copyright (c) 2010, Dragan Babic | Released under the MIT License.
 * Includes Facebox | http://defunkt.io/facebox/ | Copyright (c) 2007/2008 Chris Wanstrath  | Released under the MIT License.
 *
 * Date: Fri Mar 25 00:29:24 2011
 */

$(document).ready(function(){

	//scrolling sidebar
	
	/* not working properly
	var $scrollingDiv = $("#sidebar");
	$(window).scroll(function(){			
		
		if ($(window).scrollTop() < 100)
		{
			//do nothing
		}
		else
		{
			$scrollingDiv.stop().animate({"marginTop": ($(window).scrollTop() - 100) + "px"}, "slow" );
		}
	});
	*/
	
	//close element on click
	$(".clickClose").click(
		function () {
			$(this).slideUp(300); 
			return false;
		}
	);
	
	//back to top
	$('.backtotop').click(function(e){
		e.preventDefault();
		$('html, body').animate({scrollTop:0}, 'slow');
	});
	
	//check all
	$('.chall').click(function(){
		$(this).closest('table').find("input[type='checkbox']").attr('checked', $(this).is(':checked'));   
	});
	
	//add filters to search
	$('.filter-button').click(function(e){
		
		e.preventDefault();
		
		$('.filter-boxes').toggle('normal');
		
	});
	
	$('.filter-reset-button').click(function(e){
		
		e.preventDefault();
		
		$('input, select', $(this).parent().parent()).not(':button, :submit, :reset, :hidden').val('').removeAttr('checked').removeAttr('selected');
	});
	
	//photos gallery
	$("a[rel=gallery-1]").fancybox({
		
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			
		return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';
	}
	});

	//tipsy
	$("a[rel*=tipsy]").tipsy ({ gravity: 'n' });
	$("input[rel*=tipsy]").tipsy ({ gravity: 'n' });
	
	//facebox
	$('a[rel*=facebox]').facebox({});
	
	//datepicker fields
	$('.date-input').datepicker();
	
	//validation form
	$('#validationForm').uniform({
		prevent_submit : true
	});

	//tabs
	$('#tabs').tabs();
	
});